

export default function CreateCourse(props) {

    function createCourse(e) {
        fetch('http://127.0.0.1:8000/api/courses/', {
            method: 'POST',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json',
            },
            body: JSON.stringify({
                name: 'python 初级',
                about: 'python 入门课程，你值得拥有',
            })
        })
            .then(response => response.json())
            .then(data => {
                console.log(data);
            })
            .catch((error) => {
                console.error('Error:', error);
            });
    }

    return (
        <div className="container">
            <a class="btn btn-primary" href="#" role="button" onClick={createCourse}>Link</a>
        </div>
    )
};

